Skip to content

Improve serialization speed of enums without data in C##2762

Merged
kazimuth merged 6 commits into
masterfrom
jgilles/perf/more-enum-stuff
Jun 20, 2025
Merged

Improve serialization speed of enums without data in C##2762
kazimuth merged 6 commits into
masterfrom
jgilles/perf/more-enum-stuff

Conversation

@kazimuth

@kazimuth kazimuth commented May 20, 2025

Copy link
Copy Markdown
Contributor

Description of Changes

I was looking at a bitcraft profile and it was still spending a lot of time in reflection when deserializing enums without data -- plain-old-enums. Turns out the code I thought was dead was not. So, I changed it to be as fast as possible (indexing into an array!) This should save a few more allocations and some deserialization time. I also changed the generated .Equals for [SpacetimeDB.Type]s containing enums to avoid an allocation.

API and ABI breaking changes

Expected complexity level and risk

0

Testing

I am planning to test:

  • Bitcraft
  • Blackholio

@kazimuth kazimuth requested a review from rekhoff May 20, 2025 18:57
@kazimuth kazimuth changed the title Improve serialization speed of enums without values in C# Improve serialization speed of enums without data in C# May 20, 2025

@rekhoff rekhoff left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code, summary, comments, and tests all look good. I have not tested to verify a meaningful speed improvement but changes seem reasonable. Approved.

@bfops bfops added release-any Can land in any release window. Will not block a release deployment. performance A PR/Issue related to improving performance of stdb labels May 27, 2025
@kazimuth kazimuth force-pushed the jgilles/perf/more-enum-stuff branch from 4230824 to 22c8b68 Compare June 19, 2025 15:03
@kazimuth

kazimuth commented Jun 20, 2025

Copy link
Copy Markdown
Contributor Author

I've run through the Bitcraft tutorial and am happy with this, ready to merge.

@kazimuth kazimuth added this pull request to the merge queue Jun 20, 2025
Merged via the queue into master with commit 971ae75 Jun 20, 2025
20 checks passed
bfops added a commit to clockworklabs/com.clockworklabs.spacetimedbsdk that referenced this pull request Jun 23, 2025
## Description of Changes
Updates the DLLs for
clockworklabs/SpacetimeDB#2762, and bumps our
version numbers as well.

## API

 - [ ] This is an API breaking change to the SDK

Not a breaking change

## Requires SpacetimeDB PRs
None afaik

## Testsuite
SpacetimeDB branch name: master

## Testing
*Write instructions for a test that you performed for this PR*

- [x] Ran through Bitcraft tutorial
- [x] Blackholio on CI

---------

Co-authored-by: James Gilles <jameshgilles@gmail.com>
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
bfops added a commit that referenced this pull request Jul 17, 2025
## Description of Changes
Updates the DLLs for
#2762, and bumps our
version numbers as well.

## API

 - [ ] This is an API breaking change to the SDK

Not a breaking change

## Requires SpacetimeDB PRs
None afaik

## Testsuite
SpacetimeDB branch name: master

## Testing
*Write instructions for a test that you performed for this PR*

- [x] Ran through Bitcraft tutorial
- [x] Blackholio on CI

---------

Co-authored-by: James Gilles <jameshgilles@gmail.com>
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
bfops added a commit to clockworklabs/com.clockworklabs.spacetimedbsdk that referenced this pull request Jul 28, 2025
## Description of Changes
Updates the DLLs for
clockworklabs/SpacetimeDB#2762, and bumps our
version numbers as well.

## API

 - [ ] This is an API breaking change to the SDK

Not a breaking change

## Requires SpacetimeDB PRs
None afaik

## Testsuite
SpacetimeDB branch name: master

## Testing
*Write instructions for a test that you performed for this PR*

- [x] Ran through Bitcraft tutorial
- [x] Blackholio on CI

---------

Co-authored-by: James Gilles <jameshgilles@gmail.com>
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
@bfops bfops deleted the jgilles/perf/more-enum-stuff branch May 6, 2026 20:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance A PR/Issue related to improving performance of stdb release-any Can land in any release window. Will not block a release deployment.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants